# Copyright 2021, Régis Décamps
# SPDX-License-Identifier: BSD-3-Clause

load("@jflex_rules//jflex:jflex.bzl", "jflex")

java_library(
    name = "scanner",
    srcs = ["UcdScanner.java"],
    visibility = [
        # The compatibility test requires scanning the UnicodeData.txt
        # TODO(regisd) The test shouldn't use the same source than the impl.
        "//java/de/jflex/migration/unicodedatatest/testcompat:__pkg__",
        "//java/de/jflex/migration/unicodedatatest/testdigit:__pkg__",
        "//java/de/jflex/migration/unicodedatatest/testemoji:__pkg__",
        "//java/de/jflex/ucd_generator:__subpackages__",
        "//javatests/de/jflex:__subpackages__",
    ],
    exports = [":exception"],
    deps = [
        ":exception",
        ":ucd_scanners",
        "//java/de/jflex/ucd_generator/ucd",
        "//java/de/jflex/version",
        "//third_party/com/google/guava",
    ],
)

java_library(
    name = "ucd_scanners",
    srcs = [
        "AbstractArchaicEnumPropertyScanner.java",
        "AbstractArchaicPropListScanner.java",
        "AbstractBinaryPropertiesFileScanner.java",
        "AbstractEnumeratedPropertyFileScanner.java",
        "AbstractPropertyAliasesScanner.java",
        "AbstractPropertyValueAliasesScanner.java",
        "AbstractScriptExtensionsScanner.java",
        "AbstractUnicodeDataScanner.java",
        "DerivedAgeScanner.java",
        ":gen_ucd_scanners",
    ],
    deps = [
        "//java/de/jflex/ucd_generator/ucd",
        "//java/de/jflex/version",
        "//third_party/com/google/guava",
    ],
)

java_library(
    name = "exception",
    srcs = ["UcdScannerException.java"],
    visibility = ["//java/de/jflex/ucd_generator:__subpackages__"],
    deps = [],
)

jflex(
    name = "gen_ucd_scanners",
    srcs = glob(["*.flex"]),
    outputs = [
        "ArchaicBlocksScanner.java",
        "ArchaicLineBreakScanner.java",
        "ArchaicPropListScanner.java",
        "BinaryPropertiesFileScanner.java",
        "EnumeratedPropertyFileScanner.java",
        "PropertyAliasesScanner.java",
        "PropertyValueAliasesScanner.java",
        "ScriptExtensionsScanner.java",
        "UnicodeDataScanner.java",
    ],
    visibility = ["//java/de/jflex/ucd_generator:__subpackages__"],
)
